﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace 考核六
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\C#\考核六\k6.mdb";
            OleDbConnection myoc = new OleDbConnection();
            myoc.ConnectionString = str;
            myoc.Open();
            OleDbCommand myom = new OleDbCommand();
            string str1 = "select * from zym";
            myom.CommandText = str1;
            myom.Connection = myoc;
            OleDbDataReader myread = myom.ExecuteReader();
            List<string> zh = new List<string>();
            List<string> mm = new List<string>();
            while (myread.Read())
            {
                zh.Add((string)myread[1]);
                mm.Add((string)myread[2]);

            }
            for (int i = 0; i <= zh.Count - 1; i++)
            {
                if (textBox1.Text == zh[i] && textBox2.Text == mm[i])
                {
                    Form2 f2 = new Form2();
                    f2.Show();
                    this.Hide();
                    break;
                }
                if (i >= zh.Count - 1)
                {
                    MessageBox.Show("登录错误！");
                }
            }
        }
    }
}
